package com.ruoyi.project.configureSystem.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.configureSystem.domain.VStation;
import com.ruoyi.project.configureSystem.service.IVStationService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 厂站信息Controller
 * 
 * @author wangshuo
 * @date 2020-05-13
 */
@RestController
@RequestMapping("/configureSystem/vstation")
public class VStationController extends BaseController
{
    @Autowired
    private IVStationService vStationService;

    /**
     * 查询厂站信息列表
     */
    @PreAuthorize("@ss.hasPermi('configureSystem:vstation:list')")
    @GetMapping("/list")
    public TableDataInfo list(VStation vStation)
    {
        startPage();
        List<VStation> list = vStationService.selectVStationList(vStation);
        return getDataTable(list);
    }

    /**
     * 导出厂站信息列表
     */
    @PreAuthorize("@ss.hasPermi('configureSystem:vstation:export')")
    @Log(title = "厂站信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(VStation vStation)
    {
        List<VStation> list = vStationService.selectVStationList(vStation);
        ExcelUtil<VStation> util = new ExcelUtil<VStation>(VStation.class);
        return util.exportExcel(list, "vstation");
    }

    /**
     * 获取厂站信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('configureSystem:vstation:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(vStationService.selectVStationById(id));
    }

    /**
     * 新增厂站信息
     */
    @PreAuthorize("@ss.hasPermi('configureSystem:vstation:add')")
    @Log(title = "厂站信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody VStation vStation)
    {
        return toAjax(vStationService.insertVStation(vStation));
    }

    /**
     * 修改厂站信息
     */
    @PreAuthorize("@ss.hasPermi('configureSystem:vstation:edit')")
    @Log(title = "厂站信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody VStation vStation)
    {
        return toAjax(vStationService.updateVStation(vStation));
    }

    /**
     * 删除厂站信息
     */
    @PreAuthorize("@ss.hasPermi('configureSystem:vstation:remove')")
    @Log(title = "厂站信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(vStationService.deleteVStationByIds(ids));
    }
}
